package com.dhcc.wb.gongzhonghao;

import java.util.List;

import com.dhcc.bussiness.page.PageBean;

public class GzhService {
	
	public PageBean<GzhModel> findQiyeServiceByPage(int currentPage, int currentCount,String name) {
		GzhDao dao = new GzhDao();
		PageBean<GzhModel> pageBean = new PageBean<GzhModel>();
		try {
			pageBean.setCurrentPage(currentPage);
			pageBean.setCurrentCount(currentCount);
			Integer totalCount = dao.queryCount(name);
//			System.out.println(totalCount + "====totalCount");
			pageBean.setTotalCount(totalCount);
			int totalPage = (int) Math.ceil(1.0*totalCount/currentCount);
			pageBean.setTotalPage(totalPage);
			int startIndex = (currentPage-1)*currentCount;
			List<GzhModel> pageList = dao.findQiyeServiceByPage(startIndex, currentCount, name);
			pageBean.setPageList(pageList);
		}catch (Exception e) {
			e.printStackTrace();
		}
		return pageBean;
	}
}